package com.mihuxiaobaigao.ai.Mapper;

import com.mihuxiaobaigao.ai.pojo.OperateLog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface OperateLogMapper {

    @Insert("insert into operate_log (operate_time, method_name,  return_value, cost_time,productName,count) " +
            "values (#{operateTime},#{methodName},#{returnValue},#{costTime},#{productName},#{count})")
    void insert(OperateLog operateLog);

    @Select("select sum(count) from operate_log")
    int getRating();

    @Select("select * from (select productName,sum(count) num from operate_log group by productName) t1 order by num desc ")
    List<Map<String,Integer>> getTips();

    @Select("select productName from (select productName,sum(count) num from operate_log group by productName) t1 order by num desc limit 4")
    List<String> getNames();
}
